/**
 * Created by little star on 2017/4/20 0020.
 */
import java.lang.*;

    public class Complex {

        //定义属性并生成getter，setter
        double RealPart;
        double ImagePart;

        public double getRealPart() {
            return RealPart;
        }

        public void setRealPart(double realPart) {
            RealPart = realPart;
        }

        public double getImagePart() {
            return ImagePart;
        }

        public void setImagePart(double imagePart) {
            ImagePart = imagePart;
        }

        //定义构造函数
        public Complex(double R, double I) {
            RealPart = R;
            ImagePart = I;
        }

        //Override Object
        public boolean equals(Complex obj1) {
            if (this.getRealPart () == obj1.getRealPart () && this.getImagePart () == obj1.getImagePart ())
                return true;
            else return false;
        }

        //定义公有方法：加减乘除
        public String toString() {
            return RealPart + " + " + ImagePart + "i";
        }

        public Complex ComplexAdd(Complex obj) {
            return new Complex ( RealPart + obj.getRealPart (), ImagePart + obj.getImagePart () );
        }

        public Complex ComplexSub(Complex obj) {
            return new Complex ( RealPart - obj.getRealPart (), ImagePart - obj.getImagePart () );
        }

        public Complex ComplexMulti(Complex obj) {
            return new Complex ( RealPart * obj.getRealPart () - ImagePart * obj.getImagePart (), RealPart * obj.getImagePart () + ImagePart * obj.getRealPart () );
        }

    }
